/*
============================================================================
 Name        : BlockInfoTitle.h
 Author      : \x{738b}\x{658c}
 Version     :
 Copyright   : \x{76ca}\x{76df}\x{8f6f}\x{4ef6}
 Description : CBlockInfoTitle declaration
============================================================================
*/

#ifndef BlockInfoTitle_H
#define BlockInfoTitle_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include "BlockGoods.h"
#include "Flickable.h"

// CLASS DECLARATION

/**
*  CBlockInfoTitle
* 
*/
class TInfo
{
public:
	TInfo(const TInt16& sType, const TInt32& nGoodsID, 
		const TInt64& lOffset, const TInt& nLength, const TDesC& strTitle);

	TInfo();
public:
	TInt16 m_sType;
	TInt32 m_nGoodsID;
	TInt64 m_lOffset;
	TInt m_nLength;
	TBuf<128> m_strTitle;
};

class CBlockInfoTitle  : public CBlockGoods, public MFlickableCallback
{
public: // Constructors and destructor

	~CBlockInfoTitle();

	static CBlockInfoTitle* NewL(CBaseBlock* bsBack,const TDesC& strTitle,const TInt& sInfoType);

	static CBlockInfoTitle* NewLC(CBaseBlock* bsBack,const TDesC& strTitle,const TInt& sInfoType);

private:
	CBlockInfoTitle(CBaseBlock* bsBack,const TDesC& strTitle,const TInt& sInfoType);

	void ConstructL();

public:
	// from MFlickableCallback
	virtual TPoint ScrollOffset() const;

	virtual void SetScrollOffset(const TPoint& aOffset);

public:
	//from CBlock
	void SizeChanged();

	void OnDraw(CFbsBitGc& g)const;
	
	void OnKeyDown(TInt keyCode);

	void KeyLongPressed(const TInt& keyCode);

	TBool ReadData(const TDesC8& aData);

	void WriteData(TDes8& aBuf);

	TInt GetDataLength();

	TInt16 GetDataType();

	TInt32 GetMenuItem();

	void ChangeScrollPos(TInt nPos);

	void InitData();

	void InitPopMenu(const TInt& nType);

	TBool OnMenuEvent(TInt menuId);

	void SetInfoArray(RArray<TInfo>& aInfo, const CDesCArray* aTtrSummary = NULL, const CDesCArray* aStrTime = NULL);

	void OnMouseDown(const TPoint& aPt);

	void OnMouseMove(const TPoint& aPt);

	void OnMouseUp(const TPoint& aPt);

	void InitSummaryInfo();
	
	void ChangeFocus(TBool aFoucs, const TInt& keyCode);

protected:
	//virtual void AddTabs();
	
	void BeforeDraw(CFbsBitGc& g) const;

public: // from MTabbarObserver
	void HandleTabbarCommand(TInt aCommand);

public:
	TInt8 m_bType;
	TInt16 m_sInfoType;

private:
	RArray<TInfo> m_pInfo;
	TInt m_nCurrent;			
	TBuf<32> m_bufDownloading;
	TBuf<32> m_bufNoInfo;
	TInt m_nEllipsisWidth;

	CDesCArray* m_pstrSummary;
	CDesCArray* m_pstrTime;

	typedef enum
	{
		SingleLineTitle,
		DoubleLineTitleWithTime
	} TitleListStyle;

	TitleListStyle iTitleListStyle;
	TInt iOffset;
	TInt iHeight;
	TInt iHighlight;
	CFlickable* iFlickable;
	TRect iListRect;

	mutable TInt iStartItem;
	mutable TInt iEndItem;
};

#endif // BlockInfoTitle_H
